package jiyun.com.yiyanmeng;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.bumptech.glide.Glide;

import java.util.ArrayList;

import adapter.KechengVpAdapter;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;

public class KeChengWebActivity extends AppCompatActivity {

    private TabLayout mKechengTab;
    private ViewPager mKechengVp;
    private JCVideoPlayerStandard mPlayerListVideo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ke_cheng_web);
        initView();
        initData();
        initVido();
    }

    private void initVido() {

        JCVideoPlayerStandard player = (JCVideoPlayerStandard) findViewById(R.id.player_list_video);
        //参数一：视频连接     参数二:常量     参数三:视频标题【显示在屏幕上的标题】
        player.setUp("http://vd2.bdstatic.com/mda-jjwr4zx0d36zdqc2/hd/mda-jjwr4zx0d36zdqc2.mp4", JCVideoPlayer.SCREEN_LAYOUT_LIST, "最帅男神——杨洋");
        //参数：视频缩略图连接
        Glide.with(this).load("http://img3.imgtn.bdimg.com/it/u=2522413946,795301561&fm=26&gp=0.jpg").into(player.thumbImageView);

    }

    private void initData() {
        ArrayList<Fragment> fragments = new ArrayList<>();
        Kecheng_Mulu_Fragment mulu_fragment = new Kecheng_Mulu_Fragment();
        Kecheng_Jianjie_Fragment jianjie_fragment = new Kecheng_Jianjie_Fragment();
        Kecheng_JiaoshiJianjie_Fragment jiaoshiJianjie_Fragment = new Kecheng_JiaoshiJianjie_Fragment();
        fragments.add(mulu_fragment);
        fragments.add(jianjie_fragment);
        fragments.add(jiaoshiJianjie_Fragment);
        KechengVpAdapter kechengVpAdapter = new KechengVpAdapter(getSupportFragmentManager(), fragments);
        mKechengVp.setAdapter(kechengVpAdapter);
        mKechengTab.setupWithViewPager(mKechengVp);
        mKechengTab.getTabAt(0).setText("课程目录");
        mKechengTab.getTabAt(1).setText("课程简介");
        mKechengTab.getTabAt(2).setText("教师简介");


    }

    private void initView() {
        mKechengTab = (TabLayout) findViewById(R.id.kecheng_tab);
        mKechengVp = (ViewPager) findViewById(R.id.kecheng_vp);

        mPlayerListVideo = (JCVideoPlayerStandard) findViewById(R.id.player_list_video);
    }


}
